package com.itheima.序列化流;

import java.io.*;

public class ObjectIOStreamDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
   //  ObjectOutputStream1();
  // ObjectInputStream1();


    }

    private static void ObjectInputStream1() throws IOException, ClassNotFoundException {
        //ObjectInputStream反序列化流
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("day623-24CharStream\\xx.txt"));
        User user2 = (User) ois.readObject();
         System.out.println(user2.getUsername()+"  "+user2.getPassword());
        ois.close();
    }

    private static void ObjectOutputStream1() throws IOException {
        //ObjectOutputStream对象序列化流
        User user = new User("zhangsan", "wer");
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("day623-24CharStream\\xx.txt", true));
        oos.writeObject(user);
        oos.close();
    }
}
